package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ZhwyCashregister;
import com.ruoyi.service.IZhwyCashregisterService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 综合收银Controller
 * 
 * @author ruoyi
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/msr/cashregister")
public class ZhwyCashregisterController extends BaseController
{
    @Autowired
    private IZhwyCashregisterService zhwyCashregisterService;

    /**
     * 查询综合收银列表
     */
    @PreAuthorize("@ss.hasPermi('msr:cashregister:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZhwyCashregister zhwyCashregister)
    {
        startPage();
        List<ZhwyCashregister> list = zhwyCashregisterService.selectZhwyCashregisterList(zhwyCashregister);
        return getDataTable(list);
    }

    /**
     * 导出综合收银列表
     */
    @PreAuthorize("@ss.hasPermi('msr:cashregister:export')")
    @Log(title = "综合收银", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZhwyCashregister zhwyCashregister)
    {
        List<ZhwyCashregister> list = zhwyCashregisterService.selectZhwyCashregisterList(zhwyCashregister);
        ExcelUtil<ZhwyCashregister> util = new ExcelUtil<ZhwyCashregister>(ZhwyCashregister.class);
        util.exportExcel(response, list, "综合收银数据");
    }

    /**
     * 获取综合收银详细信息
     */
    @PreAuthorize("@ss.hasPermi('msr:cashregister:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zhwyCashregisterService.selectZhwyCashregisterById(id));
    }

    /**
     * 新增综合收银
     */
    @PreAuthorize("@ss.hasPermi('msr:cashregister:add')")
    @Log(title = "综合收银", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZhwyCashregister zhwyCashregister)
    {
        return toAjax(zhwyCashregisterService.insertZhwyCashregister(zhwyCashregister));
    }

    /**
     * 修改综合收银
     */
    @PreAuthorize("@ss.hasPermi('msr:cashregister:edit')")
    @Log(title = "综合收银", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZhwyCashregister zhwyCashregister)
    {
        return toAjax(zhwyCashregisterService.updateZhwyCashregister(zhwyCashregister));
    }

    /**
     * 删除综合收银
     */
    @PreAuthorize("@ss.hasPermi('msr:cashregister:remove')")
    @Log(title = "综合收银", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zhwyCashregisterService.deleteZhwyCashregisterByIds(ids));
    }
}
